support fetch models

This commit is contained in:
Sakurasan
2025-04-21 01:30:17 +08:00
parent d426781e47
commit 470e49b850
3 changed files with 63 additions and 1 deletions

View File

@@ -19,6 +19,7 @@ import (
"sync"
"time"
"github.com/bluele/gcache"
"github.com/gin-gonic/gin"
"github.com/lib/pq"
"github.com/tidwall/gjson"
@@ -34,6 +35,7 @@ type Proxy struct {
usageChan chan *model.Usage // 用于异步处理的channel
apikey *model.ApiKey
httpClient *http.Client
cache gcache.Cache
userDAO *dao.UserDAO
apiKeyDao *dao.ApiKeyDAO
@@ -53,12 +55,14 @@ func NewProxy(ctx context.Context, cfg *config.Config, db *gorm.DB, wg *sync.Wai
client.Transport = tr
}
}
np := &Proxy{
ctx: ctx,
cfg: cfg,
db: db,
wg: wg,
httpClient: client,
cache: gcache.New(1).Build(),
usageChan: make(chan *model.Usage, cfg.UsageChanSize),
userDAO: userDAO,
apiKeyDao: apiKeyDAO,