fix findkey

This commit is contained in:
Sakurasan
2025-04-17 20:42:08 +08:00
parent 5403ed0cba
commit 9045130778

View File

@@ -184,13 +184,9 @@ func (p *Proxy) Do(usage *model.Usage) error {
func (p *Proxy) SelectApiKey(model string) error {
akpikeys, err := p.apiKeyDao.FindApiKeysBySupportModel(p.db, model)
if err != nil {
return err
}
if len(akpikeys) == 0 {
return errors.New("no available apikey")
} else {
if strings.HasPrefix(model, "gpt") {
if err != nil || len(akpikeys) == 0 {
if strings.HasPrefix(model, "gpt") || strings.HasPrefix(model, "o1") || strings.HasPrefix(model, "o3") {
keys, err := p.apiKeyDao.FindKeys(map[string]any{"type = ?": "openai"})
if err != nil {
return err
@@ -216,7 +212,6 @@ func (p *Proxy) SelectApiKey(model string) error {
}
if len(akpikeys) == 0 {
return errors.New("no available apikey")
}
if len(akpikeys) == 1 {