cmd

package
v0.6.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunCmd = &cobra.Command{
	Use:   "run <owner/model[:version]> [input=value] ... [flags]",
	Short: `Alias for "prediction create"`,
	Args:  cobra.MinimumNArgs(1),
	RunE:  prediction.CreateCmd.RunE,
}
View Source
var ScaffoldCmd = &cobra.Command{
	Use:   "scaffold <prediction-ID-or-URL> [<directory>] [--template=<template>]",
	Short: "Create a new local development environment from a prediction",
	Args:  cobra.RangeArgs(1, 2),
	RunE: func(cmd *cobra.Command, args []string) error {
		ctx := cmd.Context()

		apiToken := os.Getenv("REPLICATE_API_TOKEN")
		if apiToken == "" {
			return fmt.Errorf("REPLICATE_API_TOKEN environment variable not set. Please set this to your Replicate API token")
		}

		client, err := replicate.NewClient(replicate.WithToken(apiToken))
		if err != nil {
			return err
		}

		predictionId, err := parsePredictionId(args[0])
		if err != nil {
			return fmt.Errorf("failed to parse prediction ID: %w", err)
		}
		prediction, err := client.GetPrediction(ctx, predictionId)
		if prediction == nil || err != nil {
			return fmt.Errorf("failed to get prediction: %w", err)
		}

		var directory string
		if len(args) == 2 {
			directory = args[1]
		} else {
			directory = predictionId
		}

		template, _ := cmd.Flags().GetString("template")

		switch template {
		case "node", "nodejs", "js", "":
			return handleNodeTemplate(ctx, prediction, directory, apiToken)
		case "python":
			return handlePythonTemplate(ctx, prediction, directory, apiToken)
		default:
			return fmt.Errorf("unsupported template: %s, expected one of: node, python", template)
		}
	},
}
View Source
var StreamCmd = &cobra.Command{
	Use:   "stream <owner/model[:version]> [input=value] ... [flags]",
	Short: `Alias for "prediction create --stream"`,
	Args:  cobra.MinimumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		err := cmd.Flags().Set("stream", "true")
		if err != nil {
			return err
		}

		return prediction.CreateCmd.RunE(cmd, args)
	},
}
View Source
var TrainCmd = &cobra.Command{
	Use:   "train <owner/model[:version]> [input=value] ... [flags]",
	Short: `Alias for "training create"`,
	Args:  cobra.MinimumNArgs(1),
	RunE:  training.CreateCmd.RunE,
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL