Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DescribeCmd = base.DescribeCmd[*hcloud.InferenceModel]{ ResourceNameSingular: "Inference Model", ShortDescription: "Describe an Inference Model", NameSuggestions: func(c hcapi2.Client) func() []string { return c.InferenceModel().Names }, Fetch: func(s state.State, _ *cobra.Command, idOrName string) (*hcloud.InferenceModel, any, error) { model, _, err := s.Client().InferenceModel().Get(s, idOrName) if err != nil { return nil, nil, err } return model, hcloud.SchemaFromInferenceModel(model), nil }, PrintText: func(s state.State, _ *cobra.Command, out io.Writer, model *hcloud.InferenceModel) error { fmt.Fprintf(out, "ID:\t%d\n", model.ID) fmt.Fprintf(out, "Name:\t%s\n", model.Name) fmt.Fprintf(out, "Description:\t%s\n", model.Description) if model.Category == "" { fmt.Fprintf(out, "Category:\t-\n") } else { fmt.Fprintf(out, "Category:\t%s\n", model.Category) } if model.ContextSize == nil { fmt.Fprintf(out, "Context Size:\t-\n") } else { fmt.Fprintf(out, "Context Size:\t%d\n", *model.ContextSize) } if model.ParameterSize == nil { fmt.Fprintf(out, "Parameter Size:\t-\n") } else { fmt.Fprintf(out, "Parameter Size:\t%s\n", *model.ParameterSize) } if model.Quantization == nil { fmt.Fprintf(out, "Quantization:\t-\n") } else { fmt.Fprintf(out, "Quantization:\t%s\n", *model.Quantization) } fmt.Fprintln(out) fmt.Fprintf(out, "Tasks:\n") if len(model.Tasks) == 0 { fmt.Fprintf(out, " No Tasks\n") } else { for _, task := range model.Tasks { fmt.Fprintf(out, " - %s\n", task) } } pricing, _, err := s.Client().Pricing().Get(s) if err != nil { return err } p, currency := model.Prices, pricing.Currency fmt.Fprintln(out) fmt.Fprintf(out, "Prices:\n") if p.Unbatched.Cached != nil || p.Unbatched.Input != nil || p.Unbatched.Output != nil || p.Unbatched.Hours != nil { fmt.Fprintf(out, " Unbatched:\n") printInferencePrice(out, p.Unbatched.Cached, "Cached (1M)", currency) printInferencePrice(out, p.Unbatched.Input, "Input (1M)", currency) printInferencePrice(out, p.Unbatched.Output, "Output (1M)", currency) printInferencePrice(out, p.Unbatched.Hours, "Hours (1h)", currency) } if p.Batched.Cached != nil || p.Batched.Input != nil || p.Batched.Output != nil || p.Batched.Hours != nil { fmt.Fprintf(out, " Batched:\n") printInferencePrice(out, p.Batched.Cached, "Cached (1M)", currency) printInferencePrice(out, p.Batched.Input, "Input (1M)", currency) printInferencePrice(out, p.Batched.Output, "Output (1M)", currency) printInferencePrice(out, p.Batched.Hours, "Hours (1h)", currency) } if deprecationText := util.DescribeDeprecation(model); deprecationText != "" { fmt.Fprintln(out) fmt.Fprint(out, deprecationText) } return nil }, Configure: experimental.Inference, }
View Source
var ListCmd = base.ListCmd[*hcloud.InferenceModel, schema.InferenceModel]{ ResourceNamePlural: "Inference Models", JSONKeyGetByName: "inference_models", DefaultColumns: []string{"id", "name", "tasks", "context_size", "parameter_size", "quantization", "deprecated"}, SortOption: nil, Fetch: func(s state.State, _ *pflag.FlagSet, listOpts hcloud.ListOpts, _ []string) ([]*hcloud.InferenceModel, error) { opts := hcloud.InferenceModelListOpts{ListOpts: listOpts} return s.Client().InferenceModel().AllWithOpts(s, opts) }, OutputTable: func(t *output.Table[*hcloud.InferenceModel], _ hcapi2.Client) { t. AddAllowedFields(&hcloud.InferenceModel{}). AddFieldFn("tasks", func(model *hcloud.InferenceModel) string { return util.NA(strings.Join(model.Tasks, ",")) }). AddFieldFn("context_size", func(model *hcloud.InferenceModel) string { if model.ContextSize == nil { return "-" } return strconv.FormatInt(*model.ContextSize, 10) }). AddFieldFn("quantization", func(model *hcloud.InferenceModel) string { if model.Quantization == nil { return "-" } return *model.Quantization }). AddFieldFn("parameter_size", func(model *hcloud.InferenceModel) string { if model.ParameterSize == nil { return "-" } return *model.ParameterSize }). AddFieldFn("deprecated", func(model *hcloud.InferenceModel) string { if !model.IsDeprecated() { return "-" } return util.Datetime(model.UnavailableAfter()) }) }, Schema: hcloud.SchemaFromInferenceModel, Configure: experimental.Inference, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.