MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / getVertexArrayKeys

Function getVertexArrayKeys

controller/channel.go:399–429  ·  view source on GitHub ↗
(keys string)

Source from the content-addressed store, hash-verified

397}
398
399func getVertexArrayKeys(keys string) ([]string, error) {
400 if keys == "" {
401 return nil, nil
402 }
403 var keyArray []interface{}
404 err := common.Unmarshal([]byte(keys), &keyArray)
405 if err != nil {
406 return nil, fmt.Errorf("批量添加 Vertex AI 必须使用标准的JsonArray格式,例如[{key1}, {key2}...],请检查输入: %w", err)
407 }
408 cleanKeys := make([]string, 0, len(keyArray))
409 for _, key := range keyArray {
410 var keyStr string
411 switch v := key.(type) {
412 case string:
413 keyStr = strings.TrimSpace(v)
414 default:
415 bytes, err := json.Marshal(v)
416 if err != nil {
417 return nil, fmt.Errorf("Vertex AI key JSON 编码失败: %w", err)
418 }
419 keyStr = string(bytes)
420 }
421 if keyStr != "" {
422 cleanKeys = append(cleanKeys, keyStr)
423 }
424 }
425 if len(cleanKeys) == 0 {
426 return nil, fmt.Errorf("批量添加 Vertex AI 的 keys 不能为空")
427 }
428 return cleanKeys, nil
429}
430
431func AddChannel(c *gin.Context) {
432 addChannelRequest := AddChannelRequest{}

Callers 1

AddChannelFunction · 0.85

Calls 1

UnmarshalFunction · 0.92

Tested by

no test coverage detected