mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-11-14 04:13:41 +08:00
refactor: add GetRatio to Adaptor
This commit is contained in:
@@ -2,14 +2,16 @@ package xunfei
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/openai"
|
||||
"github.com/songquanpeng/one-api/relay/meta"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor"
|
||||
"github.com/songquanpeng/one-api/relay/adaptor/openai"
|
||||
"github.com/songquanpeng/one-api/relay/billing/ratio"
|
||||
"github.com/songquanpeng/one-api/relay/meta"
|
||||
"github.com/songquanpeng/one-api/relay/model"
|
||||
)
|
||||
|
||||
type Adaptor struct {
|
||||
@@ -77,8 +79,12 @@ func (a *Adaptor) DoResponse(c *gin.Context, resp *http.Response, meta *meta.Met
|
||||
return
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetRatio(meta *meta.Meta) *ratio.Ratio {
|
||||
return adaptor.GetRatioHelper(meta, RatioMap)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetModelList() []string {
|
||||
return ModelList
|
||||
return adaptor.GetModelListHelper(RatioMap)
|
||||
}
|
||||
|
||||
func (a *Adaptor) GetChannelName() string {
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package xunfei
|
||||
|
||||
var ModelList = []string{
|
||||
"SparkDesk",
|
||||
"SparkDesk-v1.1",
|
||||
"SparkDesk-v2.1",
|
||||
"SparkDesk-v3.1",
|
||||
"SparkDesk-v3.1-128K",
|
||||
"SparkDesk-v3.5",
|
||||
"SparkDesk-v3.5-32K",
|
||||
"SparkDesk-v4.0",
|
||||
import "github.com/songquanpeng/one-api/relay/billing/ratio"
|
||||
|
||||
var RatioMap = map[string]ratio.Ratio{
|
||||
"SparkDesk": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v1.1": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v2.1": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v3.1": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v3.1-128K": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v3.5": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v3.5-32K": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
"SparkDesk-v4.0": {Input: 1.2858, Output: 1.2858}, // ¥0.018 / 1k tokens
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user