package cli import ( "fmt" "github.com/spf13/cobra" "gitea.mynodes.xyz/ilker/llmgw/internal/agent/provision" "gitea.mynodes.xyz/ilker/llmgw/internal/control/adminapi" "gitea.mynodes.xyz/ilker/llmgw/internal/control/catalog" "gitea.mynodes.xyz/ilker/llmgw/internal/settings" ) func newModelPresetsCmd() *cobra.Command { return &cobra.Command{ Use: "presets", Short: "The models that come with llmgw, added by name", Long: "Each is a catalog entry whose workflow, custom nodes, packages and licence\n" + "were found and tried, and whose profile says the card it needs rather than\n" + "a class, so it places on any site's cards. Add one with\n" + "`llmgw ctl model add NAME`.", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, _ []string) error { w := tabTo(cmd.OutOrStdout()) fmt.Fprintln(w, "NAME\tMAKES\tCARD\tLICENCE\tWHAT IT IS FOR") for _, p := range catalog.Presets() { fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", p.Model.Name, p.Makes, presetCard(p.Model), presetLicence(p.Model), p.Model.Description) } return w.Flush() }, } } func presetCard(m catalog.Model) string { if len(m.Profiles) == 0 || m.Profiles[0].GPU == nil { return "—" } return m.Profiles[0].GPU.String() } func presetLicence(m catalog.Model) string { if m.License == nil { return "—" } l := m.License.Name if c := m.License.Commercial; c != nil && !*c { l += ", not commercial" } return l } // ensureComfyUI has the nodes install ComfyUI for a model that needs it, // unless the cluster names a version already, or none on purpose. func ensureComfyUI(cmd *cobra.Command, client func() *ctlClient, model string) error { out := cmd.OutOrStdout() path := []string{"engines", catalog.EngineComfyUI} var cur adminapi.SettingsView if err := client().get(cmd.Context(), "/api/v1/settings", &cur); err != nil { return err } doc, err := settings.FromBytes("settings", []byte(cur.Body)) if err != nil { return err } version := provision.ComfyUIVersion() if n := doc.Node(path); n != nil { if n.Value == "" { fmt.Fprintf(out, "engines.comfyui is set to none, so the nodes install no ComfyUI for it: set a version "+ "(llmgw ctl config set engines.comfyui %s) or name one installed by hand in agent.yaml\n", version) } return nil } fmt.Fprintf(out, "Nodes with an NVIDIA GPU install ComfyUI %s for it, about 10 GB each:\n", version) if err := doc.SetYAML(path, version); err != nil { return err } b, err := doc.Bytes() if err != nil { return err } return putSettings(cmd, client, cur, b, "ComfyUI for "+model) }