mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-14 12:23:41 +08:00
refactor: add GetRatio to Adaptor
This commit is contained in:
@@ -3,15 +3,16 @@ package baidu
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/songquanpeng/one-api/relay/meta"
|
||||
"github.com/songquanpeng/one-api/relay/relaymode"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor"
|
||||
"github.com/songquanpeng/one-api/relay/billing/ratio"
|
||||
"github.com/songquanpeng/one-api/relay/meta"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
"github.com/songquanpeng/one-api/relay/relaymode"
|
||||
)
|
||||
|
||||
type Adaptor struct {
|
||||
@@ -120,6 +121,10 @@ func (a *Adaptor) DoRequest(c *gin.Context, meta *meta.Meta, requestBody io.Read
|
||||
return adaptor.DoRequestHelper(a, c, meta, requestBody)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetRatio(meta *meta.Meta) *ratio.Ratio {
|
||||
return adaptor.GetRatioHelper(meta, RatioMap)
|
||||
}
|
||||
|
||||
func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Meta) (usage *model.Usage, err *model.ErrorWithStatusCode) {
|
||||
if meta.IsStream {
|
||||
err, usage = StreamHandler(c, resp)
|
||||
@@ -135,7 +140,7 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Met
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetModelList() []string {
|
||||
return ModelList
|
||||
return adaptor.GetModelListHelper(RatioMap)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetChannelName() string {
|
||||
|
||||
@@ -1,20 +1,38 @@
|
||||
package baidu
|
||||
|
||||
var ModelList = []string{
|
||||
"ERNIE-4.0-8K",
|
||||
"ERNIE-3.5-8K",
|
||||
"ERNIE-3.5-8K-0205",
|
||||
"ERNIE-3.5-8K-1222",
|
||||
"ERNIE-Bot-8K",
|
||||
"ERNIE-3.5-4K-0205",
|
||||
"ERNIE-Speed-8K",
|
||||
"ERNIE-Speed-128K",
|
||||
"ERNIE-Lite-8K-0922",
|
||||
"ERNIE-Lite-8K-0308",
|
||||
"ERNIE-Tiny-8K",
|
||||
"BLOOMZ-7B",
|
||||
"Embedding-V1",
|
||||
"bge-large-zh",
|
||||
"bge-large-en",
|
||||
"tao-8k",
|
||||
import "github.com/songquanpeng/one-api/relay/billing/ratio"
|
||||
|
||||
// https://cloud.baidu.com/doc/WENXINWORKSHOP/s/hlrk4akp7
|
||||
var RatioMap = map[string]ratio.Ratio{
|
||||
"ERNIE-4.0-Turbo-128K": {Input: 0.02 * ratio.RMB, Output: 0.06 * ratio.RMB},
|
||||
"ERNIE-4.0-Turbo-8K": {Input: 0.02 * ratio.RMB, Output: 0.06 * ratio.RMB},
|
||||
"ERNIE-4.0-Turbo-8K-Preview": {Input: 0.02 * ratio.RMB, Output: 0.06 * ratio.RMB},
|
||||
"ERNIE-4.0-Turbo-8K-0628": {Input: 0.02 * ratio.RMB, Output: 0.06 * ratio.RMB},
|
||||
"ERNIE-4.0-8K": {Input: 0.03 * ratio.RMB, Output: 0.09 * ratio.RMB},
|
||||
"ERNIE-4.0-8K-0613": {Input: 0.03 * ratio.RMB, Output: 0.09 * ratio.RMB},
|
||||
"ERNIE-4.0-8K-Latest": {Input: 0.03 * ratio.RMB, Output: 0.09 * ratio.RMB},
|
||||
"ERNIE-4.0-8K-Preview": {Input: 0.03 * ratio.RMB, Output: 0.09 * ratio.RMB},
|
||||
"ERNIE-3.5-128K": {Input: 0.0008 * ratio.RMB, Output: 0.002 * ratio.RMB},
|
||||
"ERNIE-3.5-8K": {Input: 0.0008 * ratio.RMB, Output: 0.002 * ratio.RMB},
|
||||
"ERNIE-3.5-8K-0701": {Input: 0.0008 * ratio.RMB, Output: 0.002 * ratio.RMB},
|
||||
"ERNIE-3.5-8K-Preview": {Input: 0.0008 * ratio.RMB, Output: 0.002 * ratio.RMB},
|
||||
"ERNIE-3.5-8K-0613": {Input: 0.0008 * ratio.RMB, Output: 0.002 * ratio.RMB},
|
||||
"ERNIE-Speed-Pro-128K": {Input: 0.0003 * ratio.RMB, Output: 0.0006 * ratio.RMB},
|
||||
"ERNIE-Novel-8K": {Input: 0.04 * ratio.RMB, Output: 0.12 * ratio.RMB},
|
||||
"ERNIE-Speed-128K": {Input: 0.1, Output: 0.1}, // 免费
|
||||
"ERNIE-Speed-8K": {Input: 0.1, Output: 0.1}, // 免费
|
||||
"ERNIE-Lite-8K": {Input: 0.1, Output: 0.1}, // 免费
|
||||
"ERNIE-Tiny-8K": {Input: 0.1, Output: 0.1}, // 免费
|
||||
"ERNIE-Functions-8K": {Input: 0.004 * ratio.RMB, Output: 0.008 * ratio.RMB},
|
||||
"ERNIE-Character-8K": {Input: 0.0003 * ratio.RMB, Output: 0.0006 * ratio.RMB},
|
||||
"ERNIE-Character-Fiction-8K": {Input: 0.0003 * ratio.RMB, Output: 0.0006 * ratio.RMB},
|
||||
"ERNIE-Character-Fiction-8K-Preview ": {Input: 0.0003 * ratio.RMB, Output: 0.0006 * ratio.RMB},
|
||||
"ERNIE-Lite-Pro-128K": {Input: 0.0002 * ratio.RMB, Output: 0.0004 * ratio.RMB},
|
||||
"Qianfan-Agent-Speed-8K": {Input: 0.0003 * ratio.RMB, Output: 0.0006 * ratio.RMB},
|
||||
"Qianfan-Agent-Lite-8K": {Input: 0.0002 * ratio.RMB, Output: 0.0004 * ratio.RMB},
|
||||
"BLOOMZ-7B": {Input: 0.004 * ratio.RMB, Output: 0.004 * ratio.RMB},
|
||||
"Embedding-V1": {Input: 0.0005 * ratio.RMB, Output: 0},
|
||||
"bge-large-zh": {Input: 0.0005 * ratio.RMB, Output: 0},
|
||||
"bge-large-en": {Input: 0.0005 * ratio.RMB, Output: 0},
|
||||
"tao-8k": {Input: 0.0005 * ratio.RMB, Output: 0},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user