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