zijiren 9 месяцев назад
Родитель
Сommit
3e5d017647
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      relay/controller/pdf.go

+ 18 - 1
relay/controller/pdf.go

@@ -1,12 +1,29 @@
 package controller
 
 import (
+	"fmt"
+
 	"github.com/gin-gonic/gin"
+	"github.com/labring/aiproxy/common/config"
 	"github.com/labring/aiproxy/relay/meta"
 )
 
 func RelayParsePdfHelper(meta *meta.Meta, c *gin.Context) *HandleResult {
 	return Handle(meta, c, func() (*PreCheckGroupBalanceReq, error) {
-		return &PreCheckGroupBalanceReq{}, nil
+		if !config.GetBillingEnabled() {
+			return &PreCheckGroupBalanceReq{}, nil
+		}
+
+		inputPrice, outputPrice, cachedPrice, cacheCreationPrice, ok := GetModelPrice(meta.ModelConfig)
+		if !ok {
+			return nil, fmt.Errorf("model price not found: %s", meta.OriginModel)
+		}
+
+		return &PreCheckGroupBalanceReq{
+			InputPrice:         inputPrice,
+			OutputPrice:        outputPrice,
+			CachedPrice:        cachedPrice,
+			CacheCreationPrice: cacheCreationPrice,
+		}, nil
 	})
 }