plugin.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package main
  2. import (
  3. init_pkg "github.com/langgenius/dify-plugin-daemon/cmd/commandline/init"
  4. "github.com/spf13/cobra"
  5. )
  6. var (
  7. pluginInitCommand = &cobra.Command{
  8. Use: "init",
  9. Short: "Init",
  10. Long: "Init",
  11. Run: func(c *cobra.Command, args []string) {
  12. init_pkg.InitPlugin()
  13. },
  14. }
  15. pluginModelCommand = &cobra.Command{
  16. Use: "model",
  17. Short: "Model",
  18. Long: "Model management for plugin",
  19. }
  20. pluginToolCommand = &cobra.Command{
  21. Use: "tool",
  22. Short: "Tool",
  23. Long: "Tool management for plugin",
  24. }
  25. pluginEndpointCommand = &cobra.Command{
  26. Use: "endpoint",
  27. Short: "Endpoint",
  28. Long: "Endpoint management for plugin",
  29. }
  30. pluginPackageCommand = &cobra.Command{
  31. Use: "package",
  32. Short: "Package",
  33. Long: "Package plugins",
  34. }
  35. pluginPermissionCommand = &cobra.Command{
  36. Use: "permission",
  37. Short: "Permission",
  38. Long: `Permission, available values:
  39. tools - allow plugin to call tools
  40. models - allow plugin to call models
  41. models.llm - allow plugin to call llm
  42. models.text_embedding - allow plugin to call text_embedding model
  43. models.rerank - allow plugin to call rerank model
  44. models.tts - allow plugin to call tts
  45. models.speech2text - allow plugin to call speech2text
  46. models.moderation - allow plugin to call moderation
  47. apps - allow plugin to call apps
  48. storage - allow plugin to use storage
  49. endpoint - allow plugin to register endpoint`,
  50. }
  51. pluginPermissionAddCommand = &cobra.Command{
  52. Use: "add permission",
  53. Short: "",
  54. Long: "Add permission to plugin, you can find the available permission by running `dify plugin permission`",
  55. }
  56. pluginPermissionDropCommand = &cobra.Command{
  57. Use: "drop permission",
  58. Short: "",
  59. Long: "Drop permission from plugin, you can find the available permission by running `dify plugin permission`",
  60. }
  61. )
  62. func init() {
  63. pluginCommand.AddCommand(pluginInitCommand)
  64. pluginCommand.AddCommand(pluginModelCommand)
  65. pluginCommand.AddCommand(pluginToolCommand)
  66. pluginCommand.AddCommand(pluginEndpointCommand)
  67. pluginCommand.AddCommand(pluginPackageCommand)
  68. pluginCommand.AddCommand(pluginPermissionCommand)
  69. pluginPermissionCommand.AddCommand(pluginPermissionAddCommand)
  70. pluginPermissionCommand.AddCommand(pluginPermissionDropCommand)
  71. }