-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: baidu keyhelp and doubao mega (#5409)
* feat: try support doubao tts icl * fix: doubao mega * fix: add baidu key help
- Loading branch information
1 parent
813e7a0
commit 692ab3a
Showing
5 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package baidu | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
"github.com/labring/sealos/service/aiproxy/relay/adaptor" | ||
) | ||
|
||
var _ adaptor.KeyValidator = (*Adaptor)(nil) | ||
|
||
func (a *Adaptor) ValidateKey(key string) error { | ||
_, _, err := getClientIDAndSecret(key) | ||
return err | ||
} | ||
|
||
func (a *Adaptor) KeyHelp() string { | ||
return "client_id|client_secret" | ||
} | ||
|
||
// key格式: client_id|client_secret | ||
func getClientIDAndSecret(key string) (string, string, error) { | ||
parts := strings.Split(key, "|") | ||
if len(parts) != 2 { | ||
return "", "", errors.New("invalid key format") | ||
} | ||
return parts[0], parts[1], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package baiduv2 | ||
|
||
import ( | ||
"errors" | ||
"strings" | ||
|
||
"github.com/labring/sealos/service/aiproxy/relay/adaptor" | ||
) | ||
|
||
var _ adaptor.KeyValidator = (*Adaptor)(nil) | ||
|
||
func (a *Adaptor) ValidateKey(key string) error { | ||
_, _, err := getAKAndSK(key) | ||
return err | ||
} | ||
|
||
func (a *Adaptor) KeyHelp() string { | ||
return "ak|sk" | ||
} | ||
|
||
// key格式: ak|sk | ||
func getAKAndSK(key string) (string, string, error) { | ||
parts := strings.Split(key, "|") | ||
if len(parts) != 2 { | ||
return "", "", errors.New("invalid key format") | ||
} | ||
return parts[0], parts[1], nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters