model.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package main
  2. import (
  3. "github.com/langgenius/dify-plugin-daemon/cmd/commandline/model"
  4. "github.com/spf13/cobra"
  5. )
  6. var (
  7. modelTemplatesCommand = &cobra.Command{
  8. Use: "templates [-t provider|model] [-m model_type] [name]",
  9. Short: "Templates",
  10. Long: "List all model templates, you can use it to create new model",
  11. Run: func(cmd *cobra.Command, args []string) {
  12. // get provider or model
  13. typ, _ := cmd.Flags().GetString("type")
  14. // get model_type
  15. model_type, _ := cmd.Flags().GetString("model_type")
  16. name := ""
  17. if len(args) > 0 {
  18. name = args[0]
  19. }
  20. model.ListTemplates(typ, model_type, name)
  21. },
  22. }
  23. newProviderCommand = &cobra.Command{
  24. Use: "provider [template] name",
  25. Short: "Provider",
  26. Long: "Using template to create new provider, one plugin only support one provider",
  27. }
  28. newModelCommand = &cobra.Command{
  29. Use: "new [template] name",
  30. Short: "Model",
  31. Long: "Using template to create new model, you need to create a provider first",
  32. }
  33. )
  34. func init() {
  35. pluginModelCommand.AddCommand(modelTemplatesCommand)
  36. pluginModelCommand.AddCommand(newProviderCommand)
  37. pluginModelCommand.AddCommand(newModelCommand)
  38. }