model.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package controllers
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/langgenius/dify-plugin-daemon/internal/service"
  5. "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
  6. "github.com/langgenius/dify-plugin-daemon/internal/types/entities/requests"
  7. )
  8. func InvokeLLM(c *gin.Context) {
  9. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeLLM]
  10. BindRequest[request](
  11. c,
  12. func(itr request) {
  13. service.InvokeLLM(&itr, c)
  14. },
  15. )
  16. }
  17. func InvokeTextEmbedding(c *gin.Context) {
  18. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeTextEmbedding]
  19. BindRequest[request](
  20. c,
  21. func(itr request) {
  22. service.InvokeTextEmbedding(&itr, c)
  23. },
  24. )
  25. }
  26. func InvokeRerank(c *gin.Context) {
  27. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeRerank]
  28. BindRequest[request](
  29. c,
  30. func(itr request) {
  31. service.InvokeRerank(&itr, c)
  32. },
  33. )
  34. }
  35. func InvokeTTS(c *gin.Context) {
  36. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeTTS]
  37. BindRequest[request](
  38. c,
  39. func(itr request) {
  40. service.InvokeTTS(&itr, c)
  41. },
  42. )
  43. }
  44. func InvokeSpeech2Text(c *gin.Context) {
  45. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeSpeech2Text]
  46. BindRequest[request](
  47. c,
  48. func(itr request) {
  49. service.InvokeSpeech2Text(&itr, c)
  50. },
  51. )
  52. }
  53. func InvokeModeration(c *gin.Context) {
  54. type request = plugin_entities.InvokePluginRequest[requests.RequestInvokeModeration]
  55. BindRequest[request](
  56. c,
  57. func(itr request) {
  58. service.InvokeModeration(&itr, c)
  59. },
  60. )
  61. }
  62. func ValidateProviderCredentials(c *gin.Context) {
  63. type request = plugin_entities.InvokePluginRequest[requests.RequestValidateProviderCredentials]
  64. BindRequest[request](
  65. c,
  66. func(itr request) {
  67. service.ValidateProviderCredentials(&itr, c)
  68. },
  69. )
  70. }
  71. func ValidateModelCredentials(c *gin.Context) {
  72. type request = plugin_entities.InvokePluginRequest[requests.RequestValidateModelCredentials]
  73. BindRequest[request](
  74. c,
  75. func(itr request) {
  76. service.ValidateModelCredentials(&itr, c)
  77. },
  78. )
  79. }