agent.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package controllers
  2. import (
  3. "net/http"
  4. "github.com/gin-gonic/gin"
  5. "github.com/langgenius/dify-plugin-daemon/internal/service"
  6. "github.com/langgenius/dify-plugin-daemon/internal/types/app"
  7. "github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
  8. "github.com/langgenius/dify-plugin-daemon/pkg/entities/requests"
  9. )
  10. func InvokeAgentStrategy(config *app.Config) gin.HandlerFunc {
  11. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeAgentStrategy]
  12. return func(c *gin.Context) {
  13. BindPluginDispatchRequest(
  14. c,
  15. func(itr request) {
  16. service.InvokeAgentStrategy(&itr, c, config.PluginMaxExecutionTimeout)
  17. },
  18. )
  19. }
  20. }
  21. func ListAgentStrategies(c *gin.Context) {
  22. BindRequest(c, func(request struct {
  23. TenantID string `uri:"tenant_id" validate:"required"`
  24. Page int `form:"page" validate:"required,min=1"`
  25. PageSize int `form:"page_size" validate:"required,min=1,max=256"`
  26. }) {
  27. c.JSON(http.StatusOK, service.ListAgentStrategies(request.TenantID, request.Page, request.PageSize))
  28. })
  29. }
  30. func GetAgentStrategy(c *gin.Context) {
  31. BindRequest(c, func(request struct {
  32. TenantID string `uri:"tenant_id" validate:"required"`
  33. PluginID string `form:"plugin_id" validate:"required"`
  34. Provider string `form:"provider" validate:"required"`
  35. }) {
  36. c.JSON(http.StatusOK, service.GetAgentStrategy(request.TenantID, request.PluginID, request.Provider))
  37. })
  38. }