MCPcopy Create free account
hub / github.com/tbphp/gpt-load / AddMultipleKeys

Method AddMultipleKeys

internal/handler/key_handler.go:82–110  ·  view source on GitHub ↗

AddMultipleKeys handles creating new keys from a text block within a specific group.

(c *gin.Context)

Source from the content-addressed store, hash-verified

80
81// AddMultipleKeys handles creating new keys from a text block within a specific group.
82func (s *Server) AddMultipleKeys(c *gin.Context) {
83 var req KeyTextRequest
84 if err := c.ShouldBindJSON(&req); err != nil {
85 response.Error(c, app_errors.NewAPIError(app_errors.ErrInvalidJSON, err.Error()))
86 return
87 }
88
89 if _, ok := s.findGroupByID(c, req.GroupID); !ok {
90 return
91 }
92
93 if !validateKeysText(c, req.KeysText) {
94 return
95 }
96
97 result, err := s.KeyService.AddMultipleKeys(req.GroupID, req.KeysText)
98 if err != nil {
99 if strings.Contains(err.Error(), "batch size exceeds the limit") {
100 response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, err.Error()))
101 } else if err.Error() == "no valid keys found in the input text" {
102 response.Error(c, app_errors.NewAPIError(app_errors.ErrValidation, err.Error()))
103 } else {
104 response.Error(c, app_errors.ParseDBError(err))
105 }
106 return
107 }
108
109 response.Success(c, result)
110}
111
112// AddMultipleKeysAsync handles creating new keys from a text block or file within a specific group.
113func (s *Server) AddMultipleKeysAsync(c *gin.Context) {

Callers

nothing calls this directly

Calls 5

findGroupByIDMethod · 0.95
ErrorFunction · 0.92
SuccessFunction · 0.92
validateKeysTextFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected