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

Method TestMultipleKeys

internal/services/key_service.go:315–339  ·  view source on GitHub ↗

TestMultipleKeys handles a one-off validation test for multiple keys.

(group *models.Group, keysText string)

Source from the content-addressed store, hash-verified

313
314// TestMultipleKeys handles a one-off validation test for multiple keys.
315func (s *KeyService) TestMultipleKeys(group *models.Group, keysText string) ([]keypool.KeyTestResult, error) {
316 keysToTest := s.ParseKeysFromText(keysText)
317 if len(keysToTest) > maxRequestKeys {
318 return nil, fmt.Errorf("batch size exceeds the limit of %d keys, got %d", maxRequestKeys, len(keysToTest))
319 }
320 if len(keysToTest) == 0 {
321 return nil, fmt.Errorf("no valid keys found in the input text")
322 }
323
324 var allResults []keypool.KeyTestResult
325 for i := 0; i < len(keysToTest); i += chunkSize {
326 end := i + chunkSize
327 if end > len(keysToTest) {
328 end = len(keysToTest)
329 }
330 chunk := keysToTest[i:end]
331 results, err := s.KeyValidator.TestMultipleKeys(group, chunk)
332 if err != nil {
333 return nil, err
334 }
335 allResults = append(allResults, results...)
336 }
337
338 return allResults, nil
339}
340
341// StreamKeysToWriter fetches keys from the database in batches and writes them to the provided writer.
342func (s *KeyService) StreamKeysToWriter(groupID uint, statusFilter string, writer io.Writer) error {

Callers

nothing calls this directly

Calls 1

ParseKeysFromTextMethod · 0.95

Tested by

no test coverage detected