feat: update api key last_use_time after dalle3 call

This commit is contained in:
RockYang
2024-01-04 18:15:00 +08:00
parent ea3301c75c
commit 1ddd05302b
6 changed files with 39 additions and 61 deletions

View File

@@ -11,6 +11,7 @@ import (
"io"
"net/http"
"net/url"
"time"
)
var logger = logger2.GetLogger()
@@ -121,5 +122,8 @@ func OpenAIRequest(db *gorm.DB, prompt string, proxy string) (string, error) {
return "", fmt.Errorf("error with http request: %v%v%s", err, r.Err, errRes.Error.Message)
}
// 更新 API KEY 的最后使用时间
db.Model(&apiKey).UpdateColumn("last_used_at", time.Now().Unix())
return response.Choices[0].Message.Content, nil
}