Documentation ¶
Index ¶
Constants ¶
View Source
const ( // PredictionStatusStarting - the prediction is starting up. If this status lasts longer than a few seconds, then it's typically because a new worker is being started to run the prediction. PredictionStatusStarting = "starting" // PredictionStatusProcessing - the predict() method of the model is currently running. PredictionStatusProcessing = "processing" // PredictionStatusSucceeded - the prediction completed successfully. PredictionStatusSucceeded = "succeeded" // PredictionStatusFailed - the prediction encountered an error during processing. PredictionStatusFailed = "failed" // PredictionStatusCanceled - the prediction was canceled by the user. PredictionStatusCanceled = "canceled" )
Variables ¶
View Source
var ( // URI of the replicate API URI = "https://api.replicate.com" // Version of the replicate API Version = "v1" )
View Source
var ( errors.New("unauthorized") // ErrRateLimitReached check the official docs regarding the current limits https://replicate.com/docs/reference/http#rate-limits ErrRateLimitReached = errors.New("rate limit reached") )ErrUnauthorized =
Functions ¶
func EncodeImage ¶
EncodeImage into the format accepted by replicate APIs
Types ¶
type Client ¶
type Client struct { AuthorizationToken string Owner string Model string Version string HTTPClient *http.Client }
Client for the replicate.com api. Use NewClient for smooth initialization
func (*Client) CreatePrediction ¶
func (c *Client) CreatePrediction(ctx context.Context, input map[string]interface{}) (*PredictionResult, error)
CreatePrediction will register an asynchronous prediction request with the replicate API
func (*Client) GetModelVersions ¶
func (c *Client) GetModelVersions(ctx context.Context) ([]*ModelVersion, error)
GetModelVersions will return the list of versions available for the model set in the client All the versions are sorted by the creation time
type ModelVersion ¶
type ModelVersion struct { ID string `json:"id"` CreatedAt time.Time `json:"created_at"` CogVersion string `json:"cog_version"` OpenapiSchema map[string]interface{} `json:"openapi_schema"` }
ModelVersion represents a single version of the model with the related schema
type PredictionResult ¶
type PredictionResult struct { ID string `json:"id"` Version string `json:"version"` Urls struct { Get string `json:"get"` Cancel string `json:"cancel"` } `json:"urls"` CreatedAt time.Time `json:"created_at"` StartedAt any `json:"started_at"` CompletedAt any `json:"completed_at"` Status PredictionStatus `json:"status"` Input map[string]interface{} `json:"input"` Output any `json:"output"` Error any `json:"error"` Logs any `json:"logs"` Metrics map[string]interface{} `json:"metrics"` }
PredictionResult is a represenation of a single prediction from the replicate API
type PredictionStatus ¶
type PredictionStatus = string
PredictionStatus is returned from replicate API
Click to show internal directories.
Click to hide internal directories.